#include "BieuThuc.h"
#include "BieuThucIO.h"

void main()
{
	
	BieuThucIO io;
	BieuThucIO io1;
	BieuThucIO io2;
	
	//Input du lieu tu tap tin input vao bieu thuc
	BieuThuc* bieuThuc = io.input("DulieuInput.txt");
	BieuThuc* bieuThuc1 = io1.input("DulieuInput1.txt");
	BieuThuc* bieuThuc2 = io2.input("DulieuInput2.txt");

	//Tinh gia tri cua bieu thuc
	double ketQuaGiaTri = bieuThuc->tinhGiaTri(io.layGiaTriX());
	double ketQuaGiaTri1 = bieuThuc1->tinhGiaTri(io1.layGiaTriX());
	double ketQuaGiaTri2 = bieuThuc2->tinhGiaTri(io2.layGiaTriX());


	//Tinh dao ham cua bieu thuc

	BieuThuc* ketQuaDaoHam = bieuThuc->tinhDaoHam();
	BieuThuc* ketQuaDaoHam1 = bieuThuc1->tinhDaoHam();
	BieuThuc* ketQuaDaoHam2 = bieuThuc2->tinhDaoHam();

	//Output ket qua gia tri va ket qua dao ham vao tap tin output

	bool ketQua = io.output("DulieuOutput.txt", ketQuaGiaTri, ketQuaDaoHam);
	bool ketQua1 = io1.output("DulieuOutput1.txt", ketQuaGiaTri1, ketQuaDaoHam1);
	bool ketQua2 = io2.output("DulieuOutput2.txt", ketQuaGiaTri2, ketQuaDaoHam2);

	//Xuat ra man hinh console thong bao thanh cong hay that bai

	if(ketQua){
		cout << "Thuc hien output thanh cong vao file DulieuOutput.txt" << endl;
	}
	else{
		cout << "Thuc hien ouput vao file DulieuOutput.txt that bai" << endl;
	}
	
	if(ketQua){
		cout << "Thuc hien output thanh cong vao file DulieuOutput1.txt" << endl;
	}
	else{
		cout << "Thuc hien ouput vao file DulieuOutput1.txt that bai" << endl;
	}
	
	if(ketQua){
		cout << "Thuc hien output thanh cong vao file DulieuOutput2.txt" << endl;
	}
	else{
		cout << "Thuc hien ouput vao file DulieuOutput2.txt that bai" << endl;
	}
	
}